blob: 08faeebb76f2b4f24c9b3405d6c0308b67ac762c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
import { getServerSession } from "next-auth"
import { authOptions } from "@/app/api/auth/[...nextauth]/route"
import { getPQDataByVendorId, getPQProjectsByVendorId } from "@/lib/pq/service"
import { ClientPQWrapper } from "@/components/pq/client-pq-input-wrapper"
import { unstable_noStore as noStore } from 'next/cache'
// 페이지가 기본적으로 동적임을 나타냄
export const dynamic = "force-dynamic"
export default async function PQInputPage({
searchParams,
}: {
searchParams: { projectId?: string }
}) {
// Opt out of caching for this route
noStore()
// 세션
const session = await getServerSession(authOptions)
// 예: 세션에서 vendorId 가져오기
// const vendorId = session?.user.companyId
const vendorId = 17 // 임시
const idAsNumber = Number(vendorId)
// 서버에서는 모든 데이터를 가져오고, 프로젝트 필터링은 클라이언트에서 진행
const projectPQs = await getPQProjectsByVendorId(idAsNumber)
// 두 가지 방법으로 수정할 수 있습니다:
// 방법 1: 먼저 allPQData 데이터를 projectId 없이 가져오기
const allPQData = await getPQDataByVendorId(idAsNumber, undefined)
// 방법 2: rawProjectId를 클라이언트로 전달하고, 클라이언트가 필터링을 처리
// 클라이언트 컴포넌트로 데이터와 원시 searchParams 전달
return (
<ClientPQWrapper
allPQData={allPQData}
projectPQs={projectPQs}
vendorId={idAsNumber}
rawSearchParams={searchParams}
/>
)
}
|